package com.jjkj.environmental.environmental.view.base

import com.jjkj.environmental.environmental.exception.MvpException
import com.jjkj.environmental.environmental.utils.ActivityHelper
import java.io.IOException

/**
 * @author Administrator
 */
interface BaseView<in T> {

    fun onDataLoad(bean: T) {
        throw MvpException("此方法需要实现")
    }

    fun showToast(msg: String) {
        ActivityHelper.showToast(msg)
    }

    fun showException(throwable: Throwable) {
        when (throwable) {
            is IOException -> {
                ActivityHelper.showToast("网络连接异常")
            }
            else -> {
                ActivityHelper.showToast(throwable.message ?: "异常信息")
            }
        }
    }

}
